<template>
  <div class="player-pure">
    <div class="player-pure-container">
      <div class="player-pure-top" v-if="song">
        <!-- <div class="player-pure-top_background">
          <img v-lazy="song.pic" alt />
        </div> -->
        <div class="player-record">
          <div class="player-record-support">
            <img src="../assets/player/play-bar-support.png" alt />
          </div>
          <div
            :class="['player-record-bar', 'player-crecord-bar--' + getIsPlay]"
          >
            <img src="../assets/player/play-bar.png" alt="" />
          </div>
          <div :class="['player-pure-pic', 'player-pure-pic--' + getIsPlay]">
            <img v-lazy="song.pic" alt />
          </div>
        </div>
        <div class="player-pure-lyric">
          <div class="player-pure-lyric-desc">
            <div class="song-title">{{ song.name }}</div>
            <div class="song-artist">{{ song.artist }}</div>
            <lyric v-bind="$attrs"></lyric>
          </div>
        </div>
      </div>
      <recommends class="player-recommends" :recommends="recommends" :total="totalRecomCount" @updateRecom="updateRecom" :id="song.id"></recommends>
    </div>
  </div>
</template>
<script>
import lyric from "./player-lyric";
import Recommends from "views/list-detail/recommends";
import { _musicRecommend } from "network/detail";
export default {
  components: {
    lyric,
    Recommends,
  },
  props: {
    song: {
      type: Object,
      default: () => {},
    },
  },
  computed: {
    getIsPlay() {
      return this.$parent.isPlay ? "paused" : "running";
    },
  },
  watch: {
    song: {
      immediate: true,
      handler(song) {
        console.log(song);
        if (song.id) this.getRecom(this.offset);
      },
    },
  },
  data() {
    return {
      recommends: null,
      totalRecomCount: 0,
      limit: 30,
      offset: 1,
    };
  },
  methods: {
    /* 获取歌词评论 */
    getRecom(offset) {
      _musicRecommend(this.song.id, this.limit, offset).then((res) => {
        this.recommends = res.data.comments;
        this.totalRecomCount = res.data.total
        console.log(res.data);
      });
    },
    updateRecom(offset) {
      this.getRecom(offset)
    }
  },
};
</script>
<style scoped lang="less">
.player-pure {
  width: 100%;
  height: calc(100vh - 58px - 70px);
  position: absolute;
  bottom: 70px;
  left: 0;
  background: #fff;
  z-index: -1;
  overflow: auto;
  &-container {
    height: 100%;
    width: 100%;
    padding: 0 25%;
    position: absolute;
    z-index: -1;
  }
}
.player-pure-top {
  display: flex;
  height: 30rem;
  &_background {
    width: 50%;
    height: auto;
    background-position: center;
    position: absolute;
    top: 0;
    z-index: -1;
    img {
      width: 100%;
      height: auto;
      // opacity: 0.6;
      filter: blur(5px);
      background-size: cover;
    }
  }
}
.player-record {
  flex: 1;
  position: relative;
  &-support {
    width: 2rem;
    height: 2rem;
    position: absolute;
    top: 0px;
    right: 0px;
    left: 0px;
    margin: auto;
    z-index: -1;
    img {
      width: 1.5rem;
      height: auto;
    }
  }
  &-bar {
    width: 5rem;
    height: 7rem;
    position: absolute;
    top: 1rem;
    right: 0px;
    left: 4rem;
    margin: auto;
    z-index: 3;
    transform-origin: 0 0;
    transform: rotate(-40deg);
    transition-duration: 0.5s;
    img {
      width: 5rem;
      height: auto;
    }
  }
}
.player-crecord-bar--running {
  transform: rotate(-7deg);
  transition-duration: 0.5s;
}
.player-pure-pic {
  width: 20rem;
  height: 20rem;
  border: 3rem solid #0e0e11;
  border-radius: 50%;
  // margin: auto;
  position: absolute;
  left: 0px;
  right: 0px;
  top: 4rem;
  margin: auto;
  animation: rotate 20s linear infinite;
  img {
    width: 100%;
    border-radius: 50%;
  }
}
.player-pure-pic--paused {
  animation-play-state: paused;
}
@keyframes rotate {
  0% {
    transform: rotate(0);
  }
  100% {
    transform: rotate(1turn);
  }
}
.player-pure-lyric {
  flex: 1;
  height: 100%;
  overflow: hidden;
  &-desc {
    text-align: center;
  }
}
.player-recommends {
  padding-top: 10px;
  height: 100%;
}
</style>